package xyz.chaobei.thread.join;

/**
 * @author <a href='mailto:maruichao52@gmail.com'>MRC</a>
 * @since 2021/1/29
 */
public class Main {


    public static void main(String[] args) throws InterruptedException {

        Thread thread1 = new Thread(()-> {
           System.out.println("thread1 is runnable");
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        Thread thread2 = new Thread(()-> {
            System.out.println("thread2 is runnable");
        });

        thread1.start();
        // 让main线程等待thread1执行完毕后
        thread1.join();
        System.out.println("thread1 is terminated");
        thread2.start();
    }

}



